<template>
	<!-- 安全中心 -->
	<view>
		<view class="item" @click="navTo('/pages/address/addresslist','1')">
			<view>我的收获地址</view>
			<u-icon name="arrow-right" color="#909090" size="20"></u-icon>
		</view>
		<view class="item" @click="clear">
			<view>清除缓存</view>
			<view>
				{{num}}KB
				<!-- <u-icon name="arrow-right" color="#909090" size="20"></u-icon> -->
			</view>
		</view>
		<view class="btn" @click="outLogin">
			退出登录
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				num:""
			}
		},
		onLoad() {
			const res = uni.getStorageInfoSync()
			this.num=res.currentSize
			console.log(res)
		},
		methods: {
			// 统一跳转
			navTo(url, type) {
				// type=0不要登录 1 需要登录
				if (this.Md.islogin()) {
					uni.navigateTo({
						url: url
					})
				}
			},
			outLogin() {
				this.showMd("确认退出登录", () => {
					uni.removeStorageSync("userInfo")
					uni.removeStorageSync("user")
					let promise = this.tim.logout();
					promise.then(function(imResponse) {
					  console.log("退出登录成功",imResponse.data); // 登出成功
					}).catch(function(imError) {
					  console.warn('logout error:', imError);
					});
					uni.switchTab({
						url: "/pages/index/index"
					})
				})
			},
			clear(){
				uni.showModal({
				content: '确定要清除缓存吗',
				success: (e)=>{
					if(e.confirm){
						this.num=0
						this.msg("缓存清除成功")   
					}
				}
				});
			}
		}
	}
</script>

<style>
	.btn {
		width: 750rpx;
		height: 100rpx;
		background: #F5F5F5;
		position: fixed;
		bottom: 0;
		text-align: center;
		line-height: 100rpx;
		font-size: 28rpx;
	}

	.item {
		width: 750rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 30rpx;
		border-bottom: 1px solid #ECECEC;
		font-size: 28rpx;
		color: #333333;
	}

	.phone {
		font-size: 28rpx;
		color: #F09238;
		margin-right: 10rpx;
		font-weight: 400;
	}
</style>
